﻿
Partial Class Executed
    Inherits System.Web.UI.Page

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        General.FilterBySquadron(sqldsExecuted, ListBox1)
        General.FilterBySquadron(sqldsStaff, ListBox1)
    End Sub

    Protected Sub btnInsert_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnInsert.Click
        GridView1.ShowFooter = True
        'sqldsStaff.Insert()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Request.QueryString("id") <> "" Then
            Dim staffId As Integer
            If Integer.TryParse(Request.QueryString("id"), staffId) Then
                sqldsExecuted.FilterExpression = "id_Stratefsimos=" & staffId
            End If
        End If
    End Sub

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        General.FilterBySquadron(sqldsStaff, ListBox1)
        Select Case e.CommandName
            Case "New"
                For Each x As WebControls.Parameter In sqldsExecuted.InsertParameters
                    Dim ctrl As Web.UI.Control
                    ctrl = GridView1.FooterRow.FindControl("txt" & x.Name)
                    Dim value As String = ""
                    If ctrl IsNot Nothing Then value = CType(ctrl, TextBox).Text
                    ctrl = GridView1.FooterRow.FindControl("ddl" & x.Name)
                    If ctrl IsNot Nothing Then value = CType(ctrl, DropDownList).SelectedValue
                    If value <> "" Then x.DefaultValue = value
                Next
                sqldsExecuted.Insert()
                GridView1.ShowFooter = False
            Case "CancelNew"
                General.FilterBySquadron(sqldsExecuted, ListBox1)
                GridView1.ShowFooter = False
            Case "Edit", "Cancel"
                General.FilterBySquadron(sqldsExecuted, ListBox1)
        End Select
    End Sub

    Protected Sub sqldsExecuted_Deleted(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceStatusEventArgs) Handles sqldsExecuted.Deleted

    End Sub

    Protected Sub sqldsExecuted_Deleting(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.SqlDataSourceCommandEventArgs) Handles sqldsExecuted.Deleting

    End Sub
End Class
